package com.vfa.test;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.vfa.vocaburay.R;

public class CatagoryAdapter extends ArrayAdapter<CatagoryE>{
	
	private ArrayList<CatagoryE> items;
	private final LayoutInflater mInflater;
	private final int mLayoutRes;
	private Context context;
	private TextView tvcatagory,tvnumofcatagory;
	
	
	public CatagoryAdapter(Context context, int textViewResourceId, ArrayList<CatagoryE> cataitem) {
		super(context, textViewResourceId, cataitem);
		this.items = cataitem;
		this.context = context;
		this.mLayoutRes = textViewResourceId;
		this.mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v;
		if(convertView == null){
			v=mInflater.inflate(mLayoutRes, parent, false);
		}
		else {
			v=convertView;
		}
		final CatagoryE catagory = items.get(position);
		if(catagory !=null){
			
			tvcatagory = (TextView)v.findViewById(R.id.textView_catagoryitem);
			tvnumofcatagory = (TextView)v.findViewById(R.id.textView_catagorynumquestion);
			if(tvcatagory !=null)
			{
				tvcatagory.setText(catagory.getCatagoryName()); 
			}
			if(tvnumofcatagory !=null)
			{
				tvnumofcatagory.setText(String.valueOf(catagory.getNumquestion())+ " item");
			}
			//tvnumofcatagory.setTextColor(Color.BLUE);
		}
		return v;
	}
	
}